package cn.lctvu.servlet.client;

import cn.lctvu.bean.ItemNews;
import cn.lctvu.service.ItemNewsService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/IndexServlet")
public class IndexServlet extends HttpServlet {
    private ItemNewsService itemNewsService=new ItemNewsService();
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //读取新闻动态前6条
       List<ItemNews> listxwdt=itemNewsService.findItemNewsTop6(1);
       //读取实时资讯前6条
        List<ItemNews> listsszx=itemNewsService.findItemNewsTop6(2);
        //读取考试资讯前6条
        List<ItemNews> listkszx=itemNewsService.findItemNewsTop6(3);
        //读取一级消防工程师
        List<ItemNews> listxfgcs1=itemNewsService.findItemNewsTop6(4);
        //读取二级消防工程师
        List<ItemNews> listxfgcs2=itemNewsService.findItemNewsTop6(5);
        request.setAttribute("listxwdt",listxwdt);
        request.setAttribute("listsszx",listsszx);
        request.setAttribute("listkszx",listkszx);
        request.setAttribute("listxfgcs1",listxfgcs1);
        request.setAttribute("listxfgcs2",listxfgcs2);
        request.getRequestDispatcher("/myindex.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        doPost(request,response);
    }
}
